#!/bin/bash

set +e

IFS=$'\n\n' 

IPs="192-168-8"
ALLIPs=" '$IPs-35'"


# JobsAll=`/usr/local/bin/lotus-miner sealing jobs | grep -e $ALLIPs`
JobsAll=`/usr/local/bin/lotus-miner sealing jobs`
# JobsAll=`ls -al`
JobsANum=0
SHENYU=0

ALL=0;
AP=0;
PC1=0;
PC2=0;
C1=0;
C2=0;
FIN=0;
GET=0;
OTHER=0;
# 185 65

BASENUM=1

GPU_P1_MAX_101=`expr $BASENUM + 0`;
GPU_P1_MAX_102=`expr $BASENUM + 0`;
GPU_P1_MAX_103=`expr $BASENUM + 0`;
GPU_P1_MAX_104=`expr $BASENUM + 0`;
GPU_P1_MAX_105=`expr $BASENUM + 0`;
GPU_P1_MAX_106=`expr $BASENUM + 0`;
GPU_P1_MAX_107=`expr $BASENUM + 0`;
GPU_P1_MAX_108=`expr $BASENUM + 0`;
GPU_P1_MAX_109=`expr $BASENUM + 0`;
GPU_P1_MAX_110=`expr $BASENUM + 0`;
GPU_P1_MAX_111=`expr $BASENUM + 0`;
GPU_P1_MAX_112=`expr $BASENUM + 0`;
GPU_P1_MAX_113=`expr $BASENUM + 0`;
GPU_P1_MAX_114=`expr $BASENUM + 0`;
GPU_P1_MAX_115=`expr $BASENUM + 0`;
GPU_P1_MAX_116=`expr $BASENUM + 0`;


Jobs_GPU_101=0
Jobs_GPU_102=0
Jobs_GPU_103=0
Jobs_GPU_104=0
Jobs_GPU_105=0
Jobs_GPU_106=0
Jobs_GPU_107=0
Jobs_GPU_108=0
Jobs_GPU_109=0
Jobs_GPU_110=0
Jobs_GPU_111=0
Jobs_GPU_112=0
Jobs_GPU_113=0
Jobs_GPU_114=0
Jobs_GPU_115=0
Jobs_GPU_116=0

for i in $JobsAll
do
  
  if [ `echo $i  | awk '{print $6}'` == 'Task' ]; then
    continue
  fi

  Hos=`echo $i  | awk '{print $5$6}'`
  # 192-168-8-11PC2
  #echo $i
  # echo `echo $Hos ----`

  let ALL+=1

  Task=`echo $i  | awk '{print $6}'`

  # echo `echo $Task sssss`
  if [ "$Task" == "AP" ]; then
    let AP+=1
  elif [ "$Task" == "PC1" ]; then
    let PC1+=1
  elif [ "$Task" == "PC2" ]; then
    let PC2+=1
  elif [ "$Task" == "C1" ]; then
    let C1+=1
  elif [ "$Task" == "C2" ]; then
    let C2+=1
  elif [ "$Task" == "GET" ]; then
    let GET+=1
  elif [ "$Task" == "FIN" ]; then
    let FIN+=1
  else
    let OTHER+=1
  fi 


  if [[ ${Hos} == "192-168-8-101AP"  ]]; then
    let Jobs_GPU_101+=1
  elif [[ ${Hos} == "192-168-8-101PC1"  ]]; then
    let Jobs_GPU_101+=1
  elif [[ ${Hos} == "192-168-8-102AP"  ]]; then
    let Jobs_GPU_102+=1
  elif [[ ${Hos} == "192-168-8-102PC1"  ]]; then
    let Jobs_GPU_102+=1
  elif [[ ${Hos} == "192-168-8-103AP"  ]]; then
    let Jobs_GPU_103+=1
  elif [[ ${Hos} == "192-168-8-103PC1"  ]]; then
    let Jobs_GPU_103+=1
  elif [[ ${Hos} == "192-168-8-104AP"  ]]; then
    let Jobs_GPU_104+=1
  elif [[ ${Hos} == "192-168-8-104PC1"  ]]; then
    let Jobs_GPU_104+=1
  elif [[ ${Hos} == "192-168-8-105AP"  ]]; then
    let Jobs_GPU_105+=1
  elif [[ ${Hos} == "192-168-8-105PC1"  ]]; then
    let Jobs_GPU_105+=1
  elif [[ ${Hos} == "192-168-8-106AP"  ]]; then
    let Jobs_GPU_106+=1
  elif [[ ${Hos} == "192-168-8-106PC1"  ]]; then
    let Jobs_GPU_106+=1	

  elif [[ ${Hos} == "192-168-8-107AP"  ]]; then
    let Jobs_GPU_107+=1
  elif [[ ${Hos} == "192-168-8-107PC1"  ]]; then
    let Jobs_GPU_107+=1
  elif [[ ${Hos} == "192-168-8-108AP"  ]]; then
    let Jobs_GPU_108+=1
  elif [[ ${Hos} == "192-168-8-108PC1"  ]]; then
    let Jobs_GPU_108+=1
  elif [[ ${Hos} == "192-168-8-109AP"  ]]; then
    let Jobs_GPU_109+=1
  elif [[ ${Hos} == "192-168-8-109PC1"  ]]; then
    let Jobs_GPU_109+=1
  elif [[ ${Hos} == "192-168-8-110AP"  ]]; then
    let Jobs_GPU_110+=1
  elif [[ ${Hos} == "192-168-8-110PC1"  ]]; then
    let Jobs_GPU_110+=1
  elif [[ ${Hos} == "192-168-8-111AP"  ]]; then
    let Jobs_GPU_111+=1
  elif [[ ${Hos} == "192-168-8-111PC1"  ]]; then
    let Jobs_GPU_111+=1
  elif [[ ${Hos} == "192-168-8-112AP"  ]]; then
    let Jobs_GPU_112+=1
  elif [[ ${Hos} == "192-168-8-112PC1"  ]]; then
    let Jobs_GPU_112+=1		
	
	
  elif [[ ${Hos} == "192-168-8-113AP"  ]]; then
    let Jobs_GPU_113+=1
  elif [[ ${Hos} == "192-168-8-113PC1"  ]]; then
    let Jobs_GPU_113+=1
  elif [[ ${Hos} == "192-168-8-114AP"  ]]; then
    let Jobs_GPU_114+=1
  elif [[ ${Hos} == "192-168-8-114PC1"  ]]; then
    let Jobs_GPU_114+=1
  elif [[ ${Hos} == "192-168-8-115AP"  ]]; then
    let Jobs_GPU_115+=1
  elif [[ ${Hos} == "192-168-8-115PC1"  ]]; then
    let Jobs_GPU_115+=1
  elif [[ ${Hos} == "192-168-8-116AP"  ]]; then
    let Jobs_GPU_116+=1
  elif [[ ${Hos} == "192-168-8-116PC1"  ]]; then
    let Jobs_GPU_116+=1
	
  fi 

 

done

echo ""
echo ""
echo "-----------密封工人-------------->"

echo "JobsANum": $JobsANum
echo "ALL": $ALL
echo "AP": $AP
echo "PC1": $PC1
echo "PC2": $PC2
echo "C1": $C1
echo "C2": $C2
echo "FIN": $FIN
echo "GET": $GET

echo "GPU_P1_MAX": $GPU_P1_MAX  " => " $Jobs_GPU
GPU_P1_MAX_238=`expr $BASENUM + 0`;

echo "Jobs_GPU_101": $GPU_P1_MAX_101  " => " $Jobs_GPU_101
echo "Jobs_GPU_102": $GPU_P1_MAX_102  " => " $Jobs_GPU_102
echo "Jobs_GPU_103": $GPU_P1_MAX_103  " => " $Jobs_GPU_103
echo "Jobs_GPU_104": $GPU_P1_MAX_104  " => " $Jobs_GPU_104
echo "Jobs_GPU_105": $GPU_P1_MAX_105  " => " $Jobs_GPU_105

echo "Jobs_GPU_106": $GPU_P1_MAX_106  " => " $Jobs_GPU_106
echo "Jobs_GPU_107": $GPU_P1_MAX_107  " => " $Jobs_GPU_107
echo "Jobs_GPU_108": $GPU_P1_MAX_108  " => " $Jobs_GPU_108
echo "Jobs_GPU_109": $GPU_P1_MAX_109  " => " $Jobs_GPU_109
echo "Jobs_GPU_110": $GPU_P1_MAX_110  " => " $Jobs_GPU_110

echo "Jobs_GPU_111": $GPU_P1_MAX_111  " => " $Jobs_GPU_111
echo "Jobs_GPU_112": $GPU_P1_MAX_112  " => " $Jobs_GPU_112
echo "Jobs_GPU_113": $GPU_P1_MAX_113  " => " $Jobs_GPU_113
echo "Jobs_GPU_114": $GPU_P1_MAX_114  " => " $Jobs_GPU_114
echo "Jobs_GPU_115": $GPU_P1_MAX_115  " => " $Jobs_GPU_115

echo "Jobs_GPU_116": $GPU_P1_MAX_116  " => " $Jobs_GPU_116


if [ $Jobs_GPU_101 -le $GPU_P1_MAX_101 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 101
else
  echo "101组 密封工作已饱和..."
fi

if [ $Jobs_GPU_102 -le $GPU_P1_MAX_102 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 102
else
  echo "102组 密封工作已饱和..."
fi

if [ $Jobs_GPU_103 -le $GPU_P1_MAX_103 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 103
else
  echo "103组 密封工作已饱和..."
fi

if [ $Jobs_GPU_104 -le $GPU_P1_MAX_104 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 104
else
  echo "104组 密封工作已饱和..."
fi

if [ $Jobs_GPU_105 -le $GPU_P1_MAX_105 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 105
else
  echo "105组 密封工作已饱和..."
fi




if [ $Jobs_GPU_106 -le $GPU_P1_MAX_106 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 106
else
  echo "106组 密封工作已饱和..."
fi

if [ $Jobs_GPU_107 -le $GPU_P1_MAX_107 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 107
else
  echo "107组 密封工作已饱和..."
fi

if [ $Jobs_GPU_108 -le $GPU_P1_MAX_108 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 108
else
  echo "108组 密封工作已饱和..."
fi

if [ $Jobs_GPU_109 -le $GPU_P1_MAX_109 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 109
else
  echo "109组 密封工作已饱和..."
fi

if [ $Jobs_GPU_110 -le $GPU_P1_MAX_110 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 110
else
  echo "110组 密封工作已饱和..."
fi


if [ $Jobs_GPU_111 -le $GPU_P1_MAX_111 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 111
else
  echo "111组 密封工作已饱和..."
fi

if [ $Jobs_GPU_112 -le $GPU_P1_MAX_112 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 112
else
  echo "112组 密封工作已饱和..."
fi

if [ $Jobs_GPU_113 -le $GPU_P1_MAX_113 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 113
else
  echo "113组 密封工作已饱和..."
fi

if [ $Jobs_GPU_114 -le $GPU_P1_MAX_114 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 114
else
  echo "114组 密封工作已饱和..."
fi

if [ $Jobs_GPU_115 -le $GPU_P1_MAX_115 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 115
else
  echo "115组 密封工作已饱和..."
fi


if [ $Jobs_GPU_116 -le $GPU_P1_MAX_116 ]; then

  /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 116
else
  echo "116组 密封工作已饱和..."
fi



# if [ $Jobs_GPU_240 -le $GPU_P1_MAX_240 ]; then

#   /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 240
# else
#   echo "240组 密封工作已饱和..."
# fi


# if [ $Jobs_GPU_241 -le $GPU_P1_MAX_241 ]; then

#   /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 241
# else
#   echo "241组 密封工作已饱和..."
# fi


# if [ $Jobs_GPU_242 -le $GPU_P1_MAX_242 ]; then

#   /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 242
# else
#   echo "242组 密封工作已饱和..."
# fi


# if [ $Jobs_GPU_243 -le $GPU_P1_MAX_243 ]; then

#   /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 243
# else
#   echo "243组 密封工作已饱和..."
# fi

# if [ $Jobs_GPU_244 -le $GPU_P1_MAX_244 ]; then

#   /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 244
# else
#   echo "244组 密封工作已饱和..."
# fi

# if [ $Jobs_GPU_245 -le $GPU_P1_MAX_245 ]; then

#   /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 245
# else
#   echo "245组 密封工作已饱和..."
# fi

# if [ $Jobs_GPU_246 -le $GPU_P1_MAX_246 ]; then

#   /usr/local/bin/lotus-miner  --miner-repo /home/ceshi/.lotusminer  sectors pledge 246
# else
#   echo "246组 密封工作已饱和..."
# fi

echo "<-----------密封工人--------------"
